home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak Vol A-4
/
(Vol A-4) Vol. A4.iso
/
Games
/
smashing.swf
/
scripts
/
frame_40
/
DoAction.as
Wrap
Text File
|
2008-03-12
|
6KB
|
194 lines
function ballActions(ballpath)
{
if(!gamePaused)
{
ball = eval(ballPath);
if(ball.nextSpeedIncrease < getTimer() && maxSpeedups >= ball.speedIncreaseCounter)
{
if(maxSpeed >= makePositive(ball.SpeedX,true) && maxSpeed >= makePositive(ball.SpeedY,true))
{
if(ball.SpeedX >= 0)
{
ball.SpeedX += speedIncreaseSteps;
}
else
{
ball.SpeedX -= speedIncreaseSteps;
}
if(ball.SpeedY >= 0)
{
ball.SpeedY += speedIncreaseSteps;
}
else
{
ball.SpeedY -= speedIncreaseSteps;
}
ball.nextSpeedIncrease = getTimer() + speedIncreaseDelay;
ball.speedIncreaseCounter = ball.speedIncreaseCounter + 1;
}
}
ball.TargetX = ball._x - ball.SpeedX;
ball.TargetY = ball._y - ball.SpeedY;
if(ball.TargetX >= rightWall)
{
sndHitWall.start();
while(ball.TargetX >= rightWall)
{
ball.TargetX--;
}
ball.SpeedX = - ball.SpeedX;
ballLastBounced = getTimer();
}
if(leftWall >= ball.TargetX)
{
sndHitWall.start();
while(leftWall >= ball.TargetX)
{
ball.TargetX = ball.TargetX + 1;
}
ball.SpeedX = - ball.SpeedX;
ballLastBounced = getTimer();
}
if(topWall >= ball.TargetY)
{
sndHitWall.start();
while(topWall >= ball.TargetY)
{
ball.TargetY = ball.TargetY + 1;
}
ball.SpeedY = - ball.SpeedY;
ballLastBounced = getTimer();
}
if(ball.TargetY >= bottomWall)
{
ball.removeMovieClip();
ballsActive--;
if(ballsActive < 1)
{
readyToShootBall = false;
padsLeft--;
menu.txtPadsLeft = padsLeft;
sndExplosionShip.start();
pad.left.gotoState = "explode";
pad.right.gotoState = "explode";
pad.left.play();
pad.right.play();
}
if(padsLeft < 1 && !gameOver)
{
padsLeft = 0;
gotoAndPlay(137);
gameOver = true;
}
}
ball.pixelsMoveX = (ball.TargetX - ball._x) / iterations;
ball.pixelsMoveY = (ball.TargetY - ball._y) / iterations;
b = 1;
while(iterations >= b)
{
ball.testMoveXTemp = ball.testMoveX;
ball.testMoveYTemp = ball.testMoveY;
ball.testMoveX = ball._x + ball.pixelsMoveX * b;
ball.testMoveY = ball._y + ball.pixelsMoveY * b;
if(bricks.hitTest(ball.testMoveX,ball.testMoveY,true))
{
hitBrick(ball);
break;
}
if(pad.hitTest(ball.testMoveX,ball.testMoveY,true))
{
if(ballHitPadPause < getTimer())
{
ballHitPad(ball);
ballHitPadPause = getTimer() + 160;
}
break;
}
b++;
}
ball._x = ball.TargetX;
ball._y = ball.TargetY;
}
}
function ballBounce(ball, movieClipHit, hitSurface, hitBrickTooFast)
{
movieClipHit = eval(movieClipHit);
if(hitSurface == "top")
{
while(bricks.hitTest(ball.testMoveX,ball.testMoveY,true))
{
ball.testMoveY--;
}
ball.TargetX = ball.testMoveX;
ball.TargetY = ball.testMoveY;
ball.SpeedY = - ball.SpeedY;
}
else if(hitSurface == "bottom")
{
while(bricks.hitTest(ball.testMoveX,ball.testMoveY,true))
{
ball.testMoveY = ball.testMoveY + 1;
}
ball.TargetX = ball.testMoveX;
ball.TargetY = ball.testMoveY;
ball.SpeedY = - ball.SpeedY;
}
else if(hitSurface == "right")
{
while(bricks.hitTest(ball.testMoveX,ball.testMoveY,true))
{
ball.testMoveX = ball.testMoveX + 1;
}
ball.SpeedX = - ball.SpeedX;
ball.TargetX = ball.testMoveX;
ball.TargetY = ball.testMoveY;
}
else if(hitSurface == "left")
{
while(bricks.hitTest(ball.testMoveX,ball.testMoveY,true))
{
ball.testMoveX--;
}
ball.TargetX = ball.testMoveX;
ball.TargetY = ball.testMoveY;
ball.SpeedX = - ball.SpeedX;
}
}
function generateBall(fromPad, x, y)
{
targetClip = eval(mc);
clipCounter++;
attachMovie("mcBall","mcBall" + _root.clipCounter,_root.clipCounter);
this["mcBall" + _root.clipCounter]._x = x;
this["mcBall" + _root.clipCounter]._y = y;
ballsActive++;
do
{
this["mcBall" + _root.clipCounter].SpeedX = random(startSpeed * 2) - startSpeed;
}
while(this["mcBall" + _root.clipCounter].SpeedX == 0);
if(fromPad)
{
sndReleaseBall.start();
this["mcBall" + _root.clipCounter].SpeedY = startSpeed;
}
else
{
do
{
this["mcBall" + _root.clipCounter].SpeedY = random(startSpeed * 2) - startSpeed;
}
while(this["mcBall" + _root.clipCounter].SpeedY == 0);
}
}
speedIncreaseDelay = 2000;
speedIncreaseSteps = 0.4;
nextSpeedIncrease = getTimer() + speedIncreaseDelay;
maxSpeed = 10;
startSpeed = 5;
maxSpeedups = maxSpeed / speedIncreaseSteps - startSpeed;
iterations = 5;
gotoAndPlay(48);